﻿

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>项目字典编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <link href="../../../layuiadmin/style/mystyle.css" rel="stylesheet" />
    <script src="../../../layuiadmin/lib/api.js"></script>
    <script src="../../../layuiadmin/lib/common.js"></script>
    <script src="../../../layuiadmin/lib/jquery.min.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/lib/system.js"></script>
    <link href="../../../layuiadmin/colpick/css/colpick.css" rel="stylesheet" />
    <link href="../../../layuiadmin/colpick/css/style.css" rel="stylesheet" />
    <script src="../../../layuiadmin/colpick/js/colpick.js"></script>
    <script>
        //检查服务器是否已登录，没有登录则跳转至登录页。
        sys_islogin();
    </script>
</head>
<body>

    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
        <input type="hidden" id="ID" name="ID" />
        <input type="hidden" id="CODE" name="CODE" />
        <!--<div class="layui-form-item">
        <label class="layui-form-label">编号</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" readonly id="CODE" name="CODE" lay-verify="required" placeholder="">
        </div>

    </div>-->
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="CODENAME" name="CODENAME" lay-verify="required" placeholder="">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-inline">
                <select name="TYPE" id="TYPE" lay-verify="select_code">
                    <option value="1">任务状态</option>
                    <option value="2">任务登记</option>
                    <option value="3">任务标签</option>
                </select>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="SORTINDEX" name="SORTINDEX" placeholder="">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文字颜色</label>
            <div class="layui-input-inline">
                <div id="colorSelector" class="f-l" style="">
                    <div id="color_select" style="background-color: #000;width:190px;height:30px;"></div>
                    <input type="hidden" id="COLOR" name="COLOR" value="#000000">
                </div>
            </div>

        </div>
        <div class="layui-form-item layui-layout-admin" style="text-align:center;">
            <div class="layui-footer-new" style="background-color:#fff;">
                <button class="layui-btn" lay-submit lay-filter="save" id="save">保存</button>
                <button type="reset" lay-submit lay-filter="close" id="close" class="layui-btn layui-btn-primary">取消</button>

            </div>
        </div>
    </div>

    
    <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
      index: 'lib/index' //主入口模块
  }).use(['index', 'set', 'laydate'], function(){
      var $ = layui.$
          , form = layui.form;

      //监听提交
      form.on('submit(save)', function (data) {
          var field = data.field; //获取提交的字段
          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

          //提交 Ajax 成功后，关闭当前弹层并重载表格
          $.ajax({
              url: "/TaskDicMerber/AddOrUpdateTaskDic",    //请求的url地址
              dataType: "json",   //返回格式为json
              async: true,//请求是否异步，默认为异步，这也是ajax重要特性
              data: { arg: JSON.stringify(field) },    //参数值
              type: "POST",   //请求方式
              beforeSend: function () {
                  //请求前的处理
              },
              success: function (data) {
                  //请求成功时处理
                  if (data> 0) {
                      layer.msg("编辑成功");
                      parent.layui.table.reload('LAY-app-content-list'); //重载表格
                      parent.layer.close(index); //再执行关闭
                  }
                  else {
                      layer.msg("编辑失败，请稍后重试");
                  }
              },
              error: function (res) {
                  layer.msg("编辑失败，请联系技术人员");
              }
          });

      });

      //监听下拉框
      //form.on('select(select_code)', function (data) {
      //    var checkData = checkStatus.data; //得到选中的数据
      //    if (checkData.length === 0) {
      //        $("#STATUS option:first").prop("selected", 'selected');
      //        //$("#reset").click();
      //        return layer.msg('请选择需要修改状态的数据');
      //    }
      //    GetCodeMax(checkData);
          
      //});
     
  });

        //关闭弹窗
        $("#close").on("click", function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });

        //接收父页面的数据
        function child_fill_data(data) {
            
            for (let key in data) {
                if (key == 'COLOR') {
                    $("#color_select").css('background-color', data[key]);
                    $("#" + key).val(data[key]);       
                }      
                else $("#" + key).val(data[key]);                
            }

        };

        $('#colorSelector').colpick({
            color: '#000',
            onSubmit: function (hsb, hex, rgb, el) {
                $("#color_select").css('background-color', '#' + hex);
                $("#COLOR").val('#' + hex);
                $(el).colpickHide();
            }

        });
    </script>
</body>
</html>